<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>团长详情</title>
    <link href="../assets/css/layer.css"  />
    <link href="../assets/css/bootstrap.css" rel="stylesheet" />
    <link rel="stylesheet" href="../assets/css/bootstrapValidator.min.css" />
</head>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<style>

    h4{
        color: #6379BA;
        padding: 10px;
    }

    .input{
        color: red;
    }

    .img-thumbnail {
        width: 100px !important;
        height: 100px !important;
    }

    .close{
        float: right;
        font-size: 21px;
        font-weight: 700;
        line-height: 1;
        color: #000;
        text-shadow: 0 1px 0 #fff;
        filter: alpha(opacity=20);
        opacity: .2;
    }

    .multi-item{
        float: left;
    }
    /* body{background:#F1F1F1;}*/
</style>
<body>

<div class="form-content">
    <form id="form-user-add" class="form-horizontal">
        <input name="deptId" type="hidden" id="treeId"/>
        <hr />
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-xs-4 control-label"><span style="color: red; ">*</span>申请人姓名：</label>
                    <div class="col-xs-4" id="userId">
                        <input name="regimentalName"    placeholder="请输入团长名称" class="form-control" type="text" maxlength="20" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-xs-4 control-label">申请人电话：</label>
                    <div class="col-xs-4">
                        <input name="regimentalPhone" class="form-control email" type="text" maxlength="50" placeholder="请输入商品编码" >
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-xs-4 control-label"><span style="color: red; ">*</span>申请人小区：</label>
                    <div class="col-xs-4">
                        <input name="regimentalCommunity" placeholder="请输入商品标题" maxlength="30" class="form-control" type="text"  >
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-xs-4 control-label"><span style="color: red; ">*</span>详细地址：</label>
                    <div class="col-xs-4">
                        <div class="input-group" style="width: 100%">
                            <input name="detailAddress" placeholder="请输入商品标题" maxlength="30" class="form-control" type="text"  >
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-xs-4 control-label">申请时间：</label>
                    <div class="col-xs-4">
                        <input name="createtime" placeholder="申请时间"  class="form-control" type="text" maxlength="16" required><br>
                    </div>
                </div>
            </div>
        </div>








    </form>
</div>

<script src="../assets/js/jquery-3.4.1.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../assets/js/bootstrapValidator.min.js"></script>
<!-- <script src="../assets/js/pages-js/InternalEmployees.js" charset="utf-8"></script>-->
<script src="../assets/layui/layui-v2.5.4/layui.js" charset="utf-8"></script>
<script src="../assets/js/layer.js"></script>
</body>

<script type="text/javascript">


    $(function () {
        // queryWxGoodsType();
    });



    $("input[name='file']").on("click",function () {
        var file= document.getElementById("images").files
        alert(JSON.stringify(file));
    });

    $(".close").on("click",function () {
        $(this).parent().remove();
    });





    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        (function (jQuery, layer) {
            this.jq = jQuery;
            this.lay = layui.layer;
            this.uploadingImg = function (d, docurl, callback) {
                /*
             * 图片上传
             * d 传入当前改变的files对象
             * docurl 选择图片时获取到的系统图片路径回调
             * callback 接收到回调数据后的回调操作
             * */
                var $ = this.jq, imgInfo = $(d).prop('files')[0], lay = this.lay; //load = lay.load(1, {shade: [0.01, '#fff']});
                var getObjectURL = function (file) {
                    var url = null;
                    if (window.createObjectURL != undefined) { /*basic*/
                        url = window.createObjectURL(file);
                    } else if (window.URL != undefined) { /*mozilla(firefox)*/
                        url = window.URL.createObjectURL(file);
                    } else if (window.webkitURL != undefined) { /*webkit or chrome*/
                        url = window.webkitURL.createObjectURL(file);
                    }
                    return url;
                };
                if (imgInfo != undefined) {
                    if (/(.jpg|.jpeg|.gif|.png|.bmp|.txt)$/.test(imgInfo.name)) {
                        var imgPath = getObjectURL(imgInfo),  imgformdata = new FormData();
                        imgformdata.append("file", imgInfo);
                        $.ajax({
                            url: "/upImgController/headImgUpload", type: "post", dateType: "json"
                            , cache: false, processData: false, contentType: false, data: imgformdata
                            , success: function (res) {
                                // layer.close(load);
                                //res = JSON.parse(JSON.parse(res));
                                res=JSON.parse(res);
                                docurl(imgPath);
                                callback(res.data);
                                layer.msg("上传成功", {time: 1300});
                            }
                            , error: function () {
                                layer.msg("上传失败", {time: 1300});
                            }
                        });
                        $(d).val("");
                    } else {
                        layer.msg("请上传正确的图片格式<br/>(*.jpg,*.jpeg,*.gif,*.png,*.bmp)", {time: 1300});
                    }
                }
            };
        })(jQuery, layer);
    });

    function queryWxGoodsType() {
        $.ajax({
            type:"get",
            url:"/wxGoods/queryWxGoodsType",
            success:function (result) {
                //var goodsType="";
                $.each(result,function (i,r) {
                    var  goodsType = '<option value='+r.id+'>'+r.goods_type_name+'</option>';
                    $(".goodsType").append(goodsType);
                });
            }
        });
    }

    function addWxGoods() {
        var goodsName = $("input[name='goodsName']").val();
        var goodsSerial = $("input[name='goodsSerial']").val();
        var title = $("input[name='title']").val();
        var salesPrice = $("input[name='salesPrice']").val();
        var originalPrice = $("input[name='originalPrice']").val();
        var thePrice = $("input[name='thePrice']").val();
        var speciFications = $("input[name='speciFications']").val();
        var goodsType = $("select[name='goodsType']").val();
        var goodsNum = $("input[name='goodsNum']").val();
        var sellNum = $("input[name='sellNum']").val();
        if(goodsName!=""&&title!=""&&speciFications!=""&&goodsType!=""&&goodsNum!="")
        {

            $.post("/wxGoods/addWxGoods", {
                goodsName:goodsName,
                goodsSerial:goodsSerial,
                title:title,
                salesPrice:salesPrice,
                originalPrice:originalPrice,
                thePrice:thePrice,
                speciFications:speciFications,
                goodsType:goodsType,
                goodsNum:goodsNum,
                sellNum:sellNum
            }, function (result) {
                if (result>0) {
                    layer.msg('添加商品信息成功！',function() {time:1});
                    setInterval(function(){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },1000);
                } else {
                    layer.msg("添加商品信息失败！");
                }
            });
        }else {
            layer.msg("商品信息不能为空哦！");
        }
    }


    function getWxGoodsType(gid) {
        $.ajax({
            type:"get",
            url:"/wxGoods/queryWxGoodsType",
            success:function (result) {
                var   goodsType="";
                $.each(result,function (i,r) {
                    if(gid==r.id)
                    {
                        goodsType += '<option value='+r.id+'  selected="selected">'+r.goods_type_name+'</option>';
                    }else
                    {
                        goodsType += '<option value='+r.id+'>'+r.goods_type_name+'</option>';
                    }
                });
                $(".goodsType").html(goodsType);
            }
        });
    }


    function getRegmentalInfo(regimentalId) {
        $.ajax({
            type:"get",
            url:"/regimental/FindRegimenttalById.json?regimentalId="+regimentalId,
            success:function (result) {
                    $("input[name='regimentalName']").val(result.regimentalName);
                    $("input[name='regimentalPhone']").val(result.regimentalPhone) ;
                    $("input[name='regimentalCommunity']").val(result.regimentalCommunity) ;
                    $("input[name='detailAddress']").val(result.detailAddress) ;
                    $("input[name='regimentalStatue']").val(result.regimentalStatue) ;
                    $("input[name='createtime']").val(result.createtime) ;
            }
        });
    }

    //团长审核通过或驳回
    function updateRegimental(regimentalId,regimentalStatue) {
        alert("regimentalId==="+regimentalId);
        alert("regimentalStatue==="+regimentalStatue);
        $.post("/regimental/UpdateRegPassOrNot.json", {
            regimentalStatue:regimentalStatue,
            regimentalId:regimentalId
        }, function (result) {
            if (result>0) {
                layer.msg('修改团长状态成功！',function() {time:1});
                setInterval(function(){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                },1000);
            } else {
                layer.msg("修改团长状态失败！");
            }
        });
    }

    function updateRegimentalById(regimentalId) {
        var regimentalName = $("input[name='regimentalName']").val();
        var regimentalPhone = $("input[name='regimentalPhone']").val();
        var regimentalCommunity = $("input[name='regimentalCommunity']").val();
        var detailAddress = $("input[name='detailAddress']").val();
        //var createtime = $("input[name='createtime']").val();
       // alert("cratetime======"+createtime)
        alert("regimentalName======"+regimentalName)
        $.post("/regimental/UpdateRegimenttalById.json", {
            regimentalName:regimentalName,
            regimentalPhone:regimentalPhone,
            regimentalCommunity:regimentalCommunity,
            detailAddress:detailAddress,
           // createtime:createtime,
            regimentalId:regimentalId
        }, function (result) {
            if (result>0) {
                layer.msg('修改商品信息成功！',function() {time:1});
                setInterval(function(){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                },1000);
            } else {
                layer.msg("修改商品信息失败！");
            }
        });
    }

</script>
</html>
